import ajax from "@/common/ajax";
import mock from "../mock/index";
import { MessageAPi, ResponseData, LoginApi, UserInfoApi, PowerApi, MenuInfoApi, UserListApi, ResponseUserInfo, VisitorApi, VisitorListApi, MenuResponse, MenuListResponse } from "@/types"

const request = import.meta.env.REACT_APP_MOCK === "1" ? mock : ajax;

export const login = (data: any) => request.post("/sys/login", data) as Promise<LoginApi>;
export const getUserInfo = () => request.get("/sys/user/login/info") as Promise<UserInfoApi>;
export const getMessageList = (data: any) => request.post("/sys/message/user/page", data) as Promise<any>;
export const getMessageCount = () => request.get("/sys/message/user/count") as Promise<any>;
export const setReadAll = () => request.put("/sys/message/user/read/all", {}) as Promise<any>;


export const getDeptList = () => request.get("/sys/dept/list") as Promise<any>;
export const getRoleList = () => request.get("/sys/role/list") as Promise<any>;
export const getEmployeeList = (data: any) => request.post("/crm/employee/page", data) as Promise<any>;
export const addMember = (data: any) => request.post("/crm/employee", data) as Promise<any>;
export const editMember = (data: any) => request.put("/crm/employee", data) as Promise<any>;
export const deleteMember = (data: any) => request.delete(`/crm/employee/${data?.id}`) as Promise<any>;


export const addCustomer = (data: any) => request.post("/crm/customer", data) as Promise<any>;
export const editCustomer = (data: any) => request.put("/crm/customer", data) as Promise<any>;
export const transferCustomer = (data: any) => request.put("/crm/customer/transfer", data) as Promise<any>;
export const deleteCustomer = (data: any) => request.delete(`/crm/customer/${data?.id}`) as Promise<any>;

export const invateCustomer = (data: any) => request.post("/crm/business/order/invitation", data) as Promise<any>;
export const visitedCustomer = (data: any) => request.post("/crm/business/order/visited", data) as Promise<any>;
export const signedCustomer = (data: any) => request.post("/crm/business/order/signed", data) as Promise<any>;
export const loanCustomer = (data: any) => request.post("/crm/business/order/finished", data) as Promise<any>;
export const cancelCustomer = (data: any) => request.post("/crm/business/order/cancelled", data) as Promise<any>;

export const getFellowLog = (data: any) => request.post("/crm/customer/followUpRecord/page", data) as Promise<any>;
export const updateFellowLog = (data: any) => request.post("/crm/customer/followUpRecord", data) as Promise<any>;


export const operateLog = (data: any) => request.post("/crm/business/order/finished", data) as Promise<any>;

export const getDispatchInfo = () => request.get("/crm/config/autoDispatchOrder") as Promise<any>;
export const setDispatchInfo = (data: any) => request.post("/crm/config/autoDispatchOrder", data) as Promise<any>;
export const setReceiveInfo = ({
    employeeId, receiveStatus, receivePriority
}: any) => request.post(`/crm/employee/receiveOrdersConfig/${employeeId}`, { receiveStatus, receivePriority}) as Promise<any>;
